#include "VoERTCPObserverImpl.h"


VoERTCPObserverImpl::VoERTCPObserverImpl(void)
{
	m_mid_OnApplicationDataReceived = 0;
}


VoERTCPObserverImpl::~VoERTCPObserverImpl(void)
{
}

bool VoERTCPObserverImpl::init_jni(JNIEnv* env)
{
	bool result = false;

	do 
	{
		m_mid_OnApplicationDataReceived = (env)->GetMethodID(m_cls, "onApplicationDataReceived", "(ICI[B)V");
		if(!m_mid_OnApplicationDataReceived)
			break;

		result = true;

	} while (false);

	return result;
}

void VoERTCPObserverImpl::OnApplicationDataReceived(
	const int channel, const unsigned char subType,
	const unsigned int name, const unsigned char* data,
	const unsigned short dataLengthInBytes)
{
	JNIEnv* env = 0;

	if(before(&env))
	{
		(env)->CallVoidMethod(m_obj, m_mid_OnApplicationDataReceived,
			channel, subType, name,
			JniHelper::c2j_bytes(env, (unsigned char*)data, dataLengthInBytes));

		after(env);
	}
}